package com.mask.im.business.controller.chat;

import com.mask.im.business.model.vo.IMChatListVO;
import com.mask.im.business.common.model.RestResponse;
import com.mask.im.business.service.IMChatListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 聊天列表管理
 * @author jian
 */
@Api("聊天列表管理")
@RestController
@RequestMapping("chat")
public class IMChatListController {

    @Resource
    private IMChatListService chatListService;


    @ApiOperation("创建聊天项目")
    @PostMapping("create")
    public RestResponse<Void> creatChatData(@RequestParam Long friendId){
        chatListService.creatChatData(friendId,0);
        return RestResponse.ok();
    }

    @ApiOperation("获取聊天列表")
    @GetMapping("list")
    public RestResponse<List<IMChatListVO>> getChatList(@RequestParam(required = false) String keyword){
        return chatListService.getChatList(keyword);
    }

    @ApiOperation("清空未读")
    @GetMapping("/clearUnreadCount/{friendId}")
    public RestResponse<String> clearUnreadCount(@PathVariable Long friendId) {
        chatListService.clearUnreadCount(friendId);
        return RestResponse.ok();
    }
}
